home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.awt.util;
-
- import java.awt.Canvas;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Rectangle;
- import symantec.itools.awt.AlignStyle;
- import symantec.itools.awt.BevelStyle;
-
- public class ProgressBar extends Canvas implements BevelStyle, AlignStyle {
- public static final int INDENT_ZERO = 0;
- public static final int INDENT_ONE = 1;
- public static final int INDENT_TWO = 2;
- private int align;
- private int type;
- private int progress;
- private Color color1;
- private Color color2;
- private Color textColor;
- private Color borderedColor;
- private Color progressColor;
- private boolean bShowProgress;
- private boolean bDrawBoxes;
- private int boxWidth;
- private int gapWidth;
- // $FF: renamed from: fm java.awt.FontMetrics
- private FontMetrics field_0;
- private int xTemp;
- private int yTemp;
- private int indent;
-
- public ProgressBar() {
- this(1, 3, 0);
- }
-
- public ProgressBar(int var1, int var2, int var3) {
- this.bShowProgress = true;
- this.bDrawBoxes = false;
- this.boxWidth = 10;
- this.gapWidth = 2;
- this.textColor = Color.black;
- this.borderedColor = Color.black;
- this.progressColor = Color.blue;
- this.setBorderIndent(var3, false);
- this.setBevelStyle(var2);
- this.setAlignStyle(var1);
- }
-
- public void setProgressBarColor(Color var1) {
- this.progressColor = var1;
- ((Component)this).invalidate();
- }
-
- public Color getProgressBarColor() {
- return this.progressColor;
- }
-
- public void setProgressBarTextColor(Color var1) {
- this.textColor = var1;
- ((Component)this).invalidate();
- }
-
- public Color getProgressBarTextColor() {
- return this.textColor;
- }
-
- public boolean getDrawBoxes() {
- return this.bDrawBoxes;
- }
-
- public void setDrawBoxes(boolean var1) {
- this.bDrawBoxes = var1;
- ((Component)this).invalidate();
- }
-
- public void setBoxWidth(int var1) {
- this.boxWidth = var1;
- ((Component)this).invalidate();
- }
-
- public int getBoxWidth() {
- return this.boxWidth;
- }
-
- public void setGapWidth(int var1) {
- this.gapWidth = var1;
- ((Component)this).invalidate();
- }
-
- public int getGapWidth() {
- return this.gapWidth;
- }
-
- public boolean getShowProgress() {
- return this.bShowProgress;
- }
-
- public void setShowProgress(boolean var1) {
- this.bShowProgress = var1;
- ((Component)this).invalidate();
- }
-
- public void setAlignStyle(int var1) {
- this.align = var1;
- ((Component)this).invalidate();
- }
-
- public int getAlignStyle() {
- return this.align;
- }
-
- public void setBevelStyle(int var1) {
- this.type = var1;
- switch (this.type) {
- case 0:
- this.color1 = Color.black;
- this.color2 = Color.white;
- break;
- case 1:
- this.color1 = Color.white;
- this.color2 = Color.black;
- break;
- case 2:
- this.color1 = this.borderedColor;
- this.color2 = this.borderedColor;
- break;
- default:
- this.color1 = this.color2 = null;
- }
-
- ((Component)this).invalidate();
- }
-
- public int getBevelStyle() {
- return this.type;
- }
-
- public void setBorderIndent(int var1) {
- this.setBorderIndent(var1, true);
- }
-
- private void setBorderIndent(int var1, boolean var2) {
- if (var1 < 0) {
- this.indent = 0;
- } else if (var1 > 2) {
- this.indent = 2;
- } else {
- this.indent = var1;
- }
-
- if (var2) {
- ((Component)this).repaint();
- }
-
- }
-
- public int getBorderIndent() {
- return this.indent;
- }
-
- public void setBorderedColor(Color var1) {
- this.borderedColor = var1;
- if (this.type == 2) {
- this.color1 = var1;
- this.color2 = var1;
- }
-
- ((Component)this).invalidate();
- }
-
- public Color getBorderedColor() {
- return this.borderedColor;
- }
-
- public void updateProgress(int var1) {
- if (var1 < 0) {
- var1 = 0;
- }
-
- if (var1 > 100) {
- var1 = 100;
- }
-
- this.progress = var1;
- ((Component)this).repaint();
- }
-
- public void setValue(int var1) {
- this.updateProgress(var1);
- }
-
- public int getValue() {
- return this.progress;
- }
-
- public void update(Graphics var1) {
- this.paint(var1);
- }
-
- public void paint(Graphics var1) {
- Rectangle var2 = ((Component)this).bounds();
- Color var3 = var1.getColor();
- if (this.color1 != null) {
- var1.clipRect(0, 0, var2.width, var2.height);
- var1.setColor(this.color1);
- var1.drawLine(1 + this.indent, this.indent, var2.width - 3 - this.indent, this.indent);
- var1.setColor(this.color2);
- var1.drawLine(1 + this.indent, var2.height - 1 - this.indent, var2.width - 3 - this.indent, var2.height - 1 - this.indent);
- var1.setColor(this.color1);
- var1.drawLine(this.indent, this.indent, this.indent, var2.height - 1 - this.indent);
- var1.setColor(this.color2);
- var1.drawLine(var2.width - 2 - this.indent, this.indent, var2.width - 2 - this.indent, var2.height - 1 - this.indent);
- var1.clipRect(1 + this.indent, 1 + this.indent, var2.width - 3 - this.indent, var2.height - 2 - this.indent);
- this.yTemp = 1 + this.indent;
- } else {
- var1.setColor(((Component)this).getBackground());
- var1.drawRect(this.indent, this.indent, var2.width - 2 - this.indent, var2.height - 1 - this.indent);
- var1.clipRect(2, 1, var2.width - 3, var2.height - 2);
- this.yTemp = 1;
- }
-
- var1.setColor(this.progressColor);
- if (this.bDrawBoxes) {
- int var4 = this.boxWidth + this.gapWidth;
- int var5 = this.boxWidth * 100 / var2.width;
- int var6 = 0;
-
- for(int var7 = 0; var5 < this.progress; var5 = (var6 + this.boxWidth) * 100 / var2.width) {
- var1.setColor(this.progressColor);
- var1.fillRect(var4 * var7, 1, this.boxWidth, var2.height - 2);
- var1.setColor(((Component)this).getBackground());
- var1.fillRect(var4 * var7 + this.boxWidth, 1, this.gapWidth, var2.height - 2);
- ++var7;
- var6 = var4 * var7;
- }
-
- var1.setColor(((Component)this).getBackground());
- var1.fillRect(var6 + 1, 1, var2.width - var6 - 1, var2.height - 1);
- } else {
- var1.fillRect(1, 1, var2.width * this.progress / 100, var2.height - 1);
- var1.setColor(((Component)this).getBackground());
- var1.fillRect(1 + var2.width * this.progress / 100, 1, var2.width - var2.width * this.progress / 100, var2.height - 1);
- }
-
- if (this.bShowProgress) {
- this.field_0 = ((Component)this).getFontMetrics(((Component)this).getFont());
- this.yTemp = (var2.height + this.field_0.getAscent()) / 2 - 2;
- var1.setColor(this.textColor);
- String var8 = Integer.toString(this.progress) + "%";
- this.xTemp = (var2.width - this.field_0.stringWidth(var8)) / 2;
- switch (this.align) {
- case 0:
- if (this.type == 3) {
- var1.drawString(var8, 4, this.yTemp);
- } else {
- var1.drawString(var8, 8, this.yTemp);
- }
- break;
- case 1:
- this.xTemp = (var2.width - this.field_0.stringWidth(var8)) / 2;
- if (this.type == 3) {
- var1.drawString(var8, this.xTemp, this.yTemp);
- } else {
- var1.drawString(var8, this.xTemp, this.yTemp);
- }
- break;
- case 2:
- this.xTemp = var2.width - this.field_0.stringWidth(var8);
- if (this.type == 3) {
- var1.drawString(var8, this.xTemp - 6, this.yTemp);
- } else {
- var1.drawString(var8, this.xTemp - 10, this.yTemp);
- }
- }
- }
-
- var1.setColor(var3);
- }
-
- public Dimension preferredSize() {
- Dimension var1 = ((Component)this).size();
- Dimension var2 = this.minimumSize();
- return new Dimension(Math.max(var1.width, var2.width), Math.max(var1.height, var2.height));
- }
-
- public Dimension minimumSize() {
- this.field_0 = ((Component)this).getFontMetrics(((Component)this).getFont());
- return new Dimension(50, this.field_0.getHeight() + 4);
- }
- }
-